package com.fc.service.impl

import org.hibernate.Criteria
import org.hibernate.criterion.Restrictions
import org.springframework.stereotype.Repository
import org.springframework.transaction.annotation.Transactional

import com.fc.entities.Measurement
import com.fc.entities.MeasurementType
import com.fc.entities.User
import com.fc.service.MeasurementService

@Repository("measurementService")
@Transactional
class MeasurementServiceImpl extends BaseServiceImpl<Measurement> implements MeasurementService{
	@Override
	List<Measurement> findAllByTypeAndUser(MeasurementType type, User user) {
		Criteria criteria = currentSession().createCriteria(Measurement.class);
		criteria.add(Restrictions.eq("measurementType", type));
		criteria.add(Restrictions.eq("user", user));
		return criteria.list();
	}

	@Override
	List<Measurement> findAll() {
		findAll(Measurement.class)
	}
}
